package com.example.fechat.base

import android.app.Application
import android.content.Context
import android.graphics.drawable.Drawable
import com.example.fechat.utils.Files
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.footer.ClassicsFooter
import com.scwang.smartrefresh.layout.header.ClassicsHeader

class BaseApplication : Application() {
    companion object {
        var headers: List<Drawable?>? = null
        var application: Application? = null

        init {
            SmartRefreshLayout.setDefaultRefreshHeaderCreator { context: Context?, _: RefreshLayout? ->
                ClassicsHeader(context)
            }
            //设置全局的Footer构建器
            SmartRefreshLayout.setDefaultRefreshFooterCreator { context: Context?, _: RefreshLayout? ->
                ClassicsFooter(context).setDrawableSize(20f)
            }
        }
    }

    override fun onCreate() {
        super.onCreate()
        headers = Files.getHeadDrawable(this)
        application = this
    }
}